package demo01Array;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * @ClassName $ {NAME}
 * @Description TODO
 * @Author shenxinyuan
 * @Date $ {DATE} $ {TIME}
 * @Version 1. 0
 **/

public class KSmalleastNumbers {
    int []input = {4,5,1,6,2,7,3,8 };
    int k =4;

    public ArrayList<Integer> GetLeastNumbers_Solution(int [] input, int k) {
        Arrays.sort(input);
        ArrayList arrayList = new ArrayList();

        for(int i =0;i<k;i++){
            arrayList.add(input[i]);
        }

        return arrayList;
    }

    @Test
    public void Test(){
        System.out.println("GetLeastNumbers_Solution(input,k) = " + GetLeastNumbers_Solution(input, k));
    }
}
